package org.jeecg.modules.ncmeapis.common.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.config.swagger.BusinessApi;
import org.jeecg.modules.ncmeapis.common.service.impl.CommonServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@BusinessApi
@Api(tags = "通用接口")
@RestController
@RequestMapping("/common")
@Slf4j
public class CommonApiController {

    @ApiOperation(value = "获取城市", notes = "location直接传中文")
    @GetMapping(value = "/city/lookup")
    public Object cityLookup(@RequestParam(value = "location") String location, @RequestParam(value = "key") String key) {
        return CommonServiceImpl.cityLookup(location, key);
    }

    @ApiOperation(value = "获取城市天气", notes = "location直接传中文")
    @GetMapping(value = "/weather/now")
    public Object weatherNow(@RequestParam(value = "location") String location,
                             @RequestParam(value = "key") String key,
                             @RequestParam(value = "isDev", defaultValue = "true") Boolean isDev
    ) {
        return CommonServiceImpl.weatherNow(location, key, isDev);
    }

}
